import request from '@/sheep/request';

export default {
	// 子分类查询
	// const getCategories = () =>
	//   request({
	//     url: 'goods.goods/getCategories', // 后端接口路径，假设该接口返回分类数据
	//     method: 'get', // 你可以根据实际情况选择 GET 或 POST 请求
	//     data: {}, // 如果接口不需要传递参数，可以为空对象
	//     custom: {
	//       showLoading: false,
	//       showError: false,
	//     },
	//   });

	//浏览次数
	recordView: (id) =>
		request({
			url: 'goods.goods/recordGoodsView', // 你需要在后端创建这个接口
			method: 'POST',
			data: {
				goods_id: id,
			},
			custom: {
				showLoading: false,
				showError: false,
			},
		}),

	// 商品详情
	detail: (id, params) =>
		request({
			url: 'goods.goods/detail',
			method: 'GET',
			params: {
				id: id,
				...params,
			},
			custom: {
				showLoading: false,
				showError: false,
			},
		}),

	// 商品列表
	list: (params) =>
		request({
			url: 'goods.goods',
			method: 'GET',
			params,
			custom: {
				showLoading: false,
				showError: false,
			},
		}),
	//主页商品列表
	listindex: (params) =>
		request({
			url: 'goods.goodsindex',
			method: 'GET',
			params,
			custom: {
				showLoading: false,
				showError: false,
			},
		}),
	getCategories: (params) =>
		request({
			url: 'goods.goodsindex/getCategories',
			method: 'GET',
			params,
			custom: {
				showLoading: false,
				showError: false,
			},
		}),
	// 商品查询
	ids: (params) =>
		request({
			url: 'goods.goods/ids',
			method: 'GET',
			params,
			custom: {
				showLoading: false,
				showError: false,
			},
		}),

	// 商品评价列表
	comment: (id, params) =>
		request({
			url: 'goods.comment',
			method: 'GET',
			params: {
				goods_id: id,
				...params,
			},
			custom: {
				showLoading: false,
				showError: false,
			},
		}),
	// 商品评价类型
	getType: (id) =>
		request({
			url: 'goods.comment/getType',
			method: 'GET',
			params: {
				goods_id: id,
			},
			custom: {
				showLoading: false,
				showError: false,
			},
		}),
	// 活动商品查询
	// 商品查询
	activity: (params) =>
		request({
			url: 'goods.goods/activity',
			method: 'GET',
			params,
			custom: {
				showLoading: false,
				showError: false,
			},
		}),
	activityList: (params) =>
		request({
			url: 'goods.goods/activityList',
			method: 'GET',
			params,
		}),
};